//电池充电里程分析-电耗里程分析
define(function (){
    var chargingMileAnaly=function(params,initChart,chartWithoutData,$dataChart){
        initChart()
        $.ajaxExt({
            url : "/chargingMileAnalysis/getSocMileData.htm",
            data:params
        }).done(function(result){
            if(!result){
                chartWithoutData();
                return;
            }
            var chargeBeginTimeArr=[] ;
            var socDiffValueArr=[];
            var totalMileArr=[];
            $(result).each(function(i,item) {
                chargeBeginTimeArr.push(item.chargeBeginTime)
                socDiffValueArr.push(item.socDiffValue)
                totalMileArr.push(item.totalMile)
            })
            $dataChart.highcharts({
                title: {
                    text: ''
                },
                xAxis: {
                    categories: chargeBeginTimeArr,
                    labels: {
                        align: 'center',
                        rotation: -45,
                        y: 50
                    },
                    lineWidth: 1,
                    lineColor: '#808080'
                },
                credits: {
                    enabled: false
                },
                yAxis: [{
                    title: {
                        text: '充电量(KWh)'
                    }
                },{
                    min:0,
                    title: {
                        useHTML:true,
                        text: '运行里程(Km)'
                    },
                    opposite: true
                }],
                tooltip: {
                    shared: true,
                    valueDecimals: 2
                },
                series: [
                    {
                        name: '充电量(KWh)',
                        type: 'column',
                        color: '#FF9A00',
                        data:  socDiffValueArr
                    },
                    {
                        name: '运行里程(Km)',
                        type: 'column',
                        color: '#74C4D4',
                        yAxis: 1,
                        data: totalMileArr
                    }
                ]
            });
        });
    };
    return {
        chargingMileAnaly: chargingMileAnaly
    };
});